package GUIadapter;

import java.util.List;
import javax.swing.table.AbstractTableModel;
import ModelLayer.Employee;

@SuppressWarnings("serial")
public class EmployeeModel extends AbstractTableModel
{
	private final String[] columnHeader= {"Navn","Adresse","Postnr","By","Phone","E-mail","Brugernavn","Kodeord"};
	
	private List<Employee> employeeList;

	public EmployeeModel(List<Employee> employeeList) {
		this.employeeList = employeeList;
	}
	
	@Override
	public String getColumnName(int column) {
		return columnHeader[column];
	}

	@Override
	public int getColumnCount() {
		return columnHeader.length; //depends on amount of getters for a supplier eg.: "getName()"... very ugly
	}

	@Override
	public int getRowCount() {
		return employeeList.size();
	}

	@Override
	public Object getValueAt(int row, int col) {
		Employee employee = employeeList.get(row);
		switch(col) {
			case 0: return employee.getName();
			case 1: return employee.getAddress();
			case 2: return employee.getCity();
			case 3: return employee.getPostal();
			case 4: return employee.getEmail();
			case 5: return employee.getPhone();
			case 6: return employee.getUsername();
			case 7: return employee.getPassword();			
		}
		return null; //should never reach here..!
	}	
}
